<extend name="_layout/main"/>
<block name="head">

</block>
<block name="top">
    <header class="mui-bar mui-bar1 mui-bar-nav mui-bar-nav1" id="header">
        <a class="btn" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <div class="top-sch-box top-sch-boxtwo top-sch-boxthree flex-col">
            返回
        </div>
    </header>
</block>
<block name="content">
    <div class="warp warpthree clearfloat">
        <div class="h-top h-topone clearfloat box-s">
            <span>可倍增积分</span>
            <p><samp>{$wealth['integral']-$wealth['unstore_integral']}</samp></p>
        </div>
        <div class="recharge clearfloat">
            <div class="czhi clearfloat box-s">
                <p>转换积分</p>
                <input type="text" id="amount" name="amount" value="" placeholder="请输入需要转成待用积分值"/>
            </div>
            <div class="jfzy clearfloat">
                <ul>
                    <li>周期：{$setting.use_to_store_cycle}天 回报：{$setting.use_to_store_returns}倍</li>
                </ul>
            </div>
            <div class="guize clearfloat box-s ra3">
                <h3>转换规则</h3>
                <div class="content contenttwo clearfloat">
                    <ul>
                        <li>
                            {$setting.integral_to_stored_annouce|stripslashes|htmlspecialchars_decode}
                        </li>
                    </ul>
                </div>
            </div>
            <div class="bottom clearfloat">
                <a href="javascript:;" class="db fl btn ra3" id="btn-save">确定</a>
                <a href="javascript:history.go(-1)" class="db fr btn ra3">取消</a>
            </div>
        </div>
    </div>
</block>
<block name="scripts">
    <script>
        $(document).on('keyup', '#amount', function (e) {
            var amount = $(this).val();
            if (isNaN(amount) || parseFloat(amount) < 1) {
                mui.alert('请输入合适的积分');
                $(this).val('');
                return;
            }
        })

        $(document).on('click', '#btn-save', function (e) {
            e.preventDefault();
            var amount = $("#amount").val();
            if (!amount || isNaN(amount) || parseFloat(amount) < 1) {
                mui.alert('请输入合适的积分', '错误');
                $('#amount').val('');
                return;
            }

            $.post("{:U('Integral/tostore')}", {amount: amount}, function (xdata) {
                if (xdata.status == 'success') {
                    mui.alert(xdata.message, '提示',function () {
                        document.location.reload();
                    });
                } else {
                    mui.alert(xdata.message, '错误');
                }
            }, 'json');
        })
    </script>
</block>
